/*
 * @version: 1.0
 * @Author: zhl
 * @Date: 2021-09-06 10:50:37
 * @LastEditors: zhl
 * @LastEditTime: 2021-09-26 09:06:44
 * @Description: file content
 */
#ifndef __C_THREAD_NOTIFY_H__
#define __C_THREAD_NOTIFY_H__

#include <pthread.h>
#include <sys/time.h>


/**
 * @Description: 线程互斥锁结构体
 * @brief : 线程事件通知类封装,设计线程间通信的锁、条件变量等同步机制
 */
typedef struct _threadLock {
	pthread_mutex_t 	m_mutex;
	pthread_cond_t 		m_cond;
	pthread_mutexattr_t	m_mutexattr;
}T_THREAD_LOCK;


/**
 * @brief: 线程锁初始化
 * @function: 初始化线程锁
 * @param: threadLock 线程锁结构体
 * @return: 无
 * @note: 无
 */
extern int threadLockInit(T_THREAD_LOCK* threadLock);

/**
 * @brief: 线程锁销毁
 * @function: 销毁线程锁
 * @param: threadLock 线程锁结构体
 * @return: 无
 * @note: 无
 */
extern int threadLockDestroy(T_THREAD_LOCK* threadLock);

/**
 * @brief: 线程锁获取锁
 * @function: 获取线程锁
 * @param: threadLock 线程锁结构体
 * @return: 无
 * @note: 无
 */
extern int threadLockLock(T_THREAD_LOCK* threadLock);

/**
 * @Description: 线程互斥锁,解锁
 * @return: 无
 */
extern int threadLockUnlock(T_THREAD_LOCK* threadLock);

/**
 * @Description: 线程等待条件变量信号
 * @return: 无
 */
extern int threadLockWait(T_THREAD_LOCK* threadLock);

/**
 * @Description: 线程等待超时条件变量信号
 * @return: 无
 */
extern int threadLockTimeWait(T_THREAD_LOCK* threadLock, int ms);


/**
 * @Description: 线程触发条件变量
 * @return: 无
 */
extern int threadLockSignal(T_THREAD_LOCK* threadLock);


#endif /* __C_THREAD_NOTIFY_H__ */